package com.albert.core.service.impl;

import com.albert.core.mapper.BorrowerAttachMapper;
import com.albert.core.pojo.entity.BorrowerAttach;
import com.albert.core.pojo.vo.BorrowerAttachVO;
import com.albert.core.service.BorrowerAttachService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 借款人上传资源表 服务实现类
 * </p>
 *
 * @author Hikari
 * @since 2024-07-21
 */
@Service
public class BorrowerAttachServiceImpl extends ServiceImpl<BorrowerAttachMapper, BorrowerAttach> implements BorrowerAttachService {

    @Override
    public List<BorrowerAttachVO> selectBorrowerAttachVOList(Long borrowerId) {
        QueryWrapper<BorrowerAttach> wrapper = new QueryWrapper<>();
        wrapper.eq("borrower_id",borrowerId);
        List<BorrowerAttach> attaches = baseMapper.selectList(wrapper);
        List<BorrowerAttachVO> VOList = new ArrayList<>();
        attaches.forEach(attach -> {
            BorrowerAttachVO vo = new BorrowerAttachVO();
            vo.setImageType(attach.getImageType());
            vo.setImageUrl(attach.getImageUrl());
            VOList.add(vo);
        });
        return VOList;
    }
}
